//
//  PurseView.m
//  MyWallet
//
//  Created by 小肥羊 on 15/7/15.
//  Copyright (c) 2015年 小肥羊. All rights reserved.
//

#import "PurseView.h"

@implementation PurseView

#pragma mark - 初始化
- (id)init
{
    NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"PurseView" owner:nil options:nil];
    self = [nibs lastObject];
    if (self) {
        self.moneyView.delegate = self;
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame
{
    self = [self init];
    if (self) {
        self.frame = frame;
    }
    return self;
}


#pragma mark - 钱代理
- (void)saveMoney:(MoneyView *)moneyView
{
    if (self.delegate) {
        [self.delegate saveMoney:self];
    }
}

- (void)drawMoney:(MoneyView *)moneyView
{
    if (self.delegate) {
        [self.delegate drawMoney:self];
    }
}

#pragma mark - 公共方法
- (void)setMoney:(float)money
{
    [self.moneyLabel setText:[[NSString alloc] initWithFormat:@"$ %.2f",money]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
